package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Author:  LiuTao
 * Version: 1.0
 * Date:    2023-11-21  20:25
 */
//1.创建类来继承thread(能使用的使用，不能使用的拓展)
//2.对类进行实例化
//3.调用start()方法来启动线程
class MyThread extends Thread{
    @Override
    public void run() {
        while(true) {
            System.out.println("hello thread");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
public class ThreadDemo1 {
    public static void main(String[] args) throws InterruptedException {

        Thread thread = new MyThread();
        thread.start();

        while(true) {
            System.out.println("hello main");
            Thread.sleep(1000);
        }
    }
}
